﻿@model KhuyenMaiVang.DAL.Picture

@{
    ViewBag.Title = "Create";
    Layout = "~/Areas/Admin/Views/Shared/_AdminLayout.cshtml";
}

@section heading{Thêm hình ảnh}

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>Picture</legend>

        <div class="editor-label">
            @Html.LabelFor(model => model.URL)
        </div>
        <div class="editor-field">
            @Html.HiddenFor(model => model.URL)
            @Html.ValidationMessageFor(model => model.URL)
        </div>

        <!-- Ajax upload avatar -->
        <script src="@Url.Content("~/Content/scripts/ajaxupload/fileuploader.js")" type="text/javascript"></script>
        <link href="@Url.Content("~/Content/scripts/ajaxupload/fileuploader.css")" rel="stylesheet" type="text/css" />
        <script type="text/javascript">
            function createUploader() {
                var uploader = new qq.FileUploader({
                    element: document.getElementById('file-uploader'),
                    action: '/Admin/Helper/Upload/',
                    debug: true,
                    multiple: false,
                    allowedExtensions: ['jpg', 'jpeg', 'png', 'gif'],
                    onComplete: function (file, response) {
                        var fullName = "/content/kmvdata/avatars/" + response;
                        $('#previewAvatar').attr('src', fullName);
                        $('#previewAvatar').height(100);
                        $('input[id=URL]').val(fullName);
                    }
                });
            }
            window.onload = createUploader;     
        </script>
        <div id="file-uploader">
            
        </div>
        <img alt="" id="previewAvatar" src="" height=""/>

        <div class="editor-label">
            @Html.LabelFor(model => model.VoucherID, "Voucher")
        </div>
        <div class="editor-field">
            @Html.DropDownList("VoucherID", String.Empty)
            @Html.ValidationMessageFor(model => model.VoucherID)
        </div>

        <p>
            <input class="button" type="submit" value="Create" />
        </p>
    </fieldset>
}

<div>
    @Html.ActionLink("Quay lại", "Index")
</div>
